#!/bin/bash -e

function info() {
echo Usage: `basename $0` '1_r1.fq 2_r1.fq [...]'
exit 2
}

while getopts  ":p:f:" opt; do
	case  $opt  in
		p) out_prefix=$OPTARG;;
		f) suffix=$OPTARG;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then info; fi

. $var

base=`basename $1|cut -f1 -d_`


for fil; do
    dir=`dirname $fil` # $dir maybe different
    r2="$r2 $dir/`basename $fil|sed s/_R1_/_R2_/`"
    echo $fil
    echo $r2
done
    

zcat $@ > ${base}_r1.fq

zcat $r2 > ${base}_r2.fq

gzip ${base}_r1.fq ${base}_r2.fq

